
#include "CommonHeader.h"

void DEBUGPrint()
{
#if defined  _WIN32 || defined _WIN64
    DWORD   dwLastError = ::GetLastError();
    TCHAR   lpBuffer[512] = _T("?");
    if(dwLastError != 0)
    {
        ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,    // ItŽs a system error
                        NULL,                                      // No string to be formatted needed
                        dwLastError,                               // Hey Windows: Please explain this error!
                        MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),  // Do it in the standard language
                        lpBuffer,              // Put the message here
                        sizeof(lpBuffer)-1,                     // Number of bytes to store the message
                        NULL);
        wcout << L"Error:  code : "  << dwLastError << " Reason : " << lpBuffer << endl;
    }
#elif defined __linux__
    wcout << "Error:  code : "  << errno  << " Reason : " << strerror(errno) << endl;
#endif
}


